<template>
  <!-- prettier-ignore -->
  <el-dialog :visible.sync="visible" :close-on-click-modal="false">
    <div slot="title" class="align-cm">
      <b class="fc-gray10">编辑描述</b>
    </div>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="描述">
        <el-input type="textarea" v-model="form.desc"></el-input>
      </el-form-item>
    </el-form>
    <!-- <pre>{{ tempData }}</pre> -->
    <span slot="footer" class="dialog-footer">
      <el-button size="small" @click="cancel">取消</el-button>
      <el-button size="small" type="primary" @click="submit">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { bus } from "@/main.js";
export default {
  name: "editorsNote",
  data() {
    return {
      isDev: process.env.NODE_ENV == "development",
      visible: false,
      tempData: null,
      form: {
        desc: "",
      },
    };
  },
  computed: {
    arg: function () {
      return Object.assign(
        {
          id: this._.get(this.tempData, "id", ""),
          descriptions: this.form.desc,
        },
        this.$store.getters["userInfo/getEmployee"]
      );
    },
  },
  methods: {
    init: function (tempDate) {
      this.visible = true;
      this.tempData = tempDate;
      this.form.desc = this._.get(tempDate, "description", "");
    },
    close: function () {
      this.visible = false;
      this.tempData = null;
    },
    cancel: function () {
      this.close();
    },
    submit: function () {
      let arg = this.arg;
      this.$api
        .updata某客户描述(arg, {})
        .then((res) => {
          if (res.code == 200) {
            this.$message({
              message: "修改成功",
              type: "success",
            });
            bus.$emit("更新某客户描述", {
              id: arg.id,
              description: arg.descriptions,
            });
            return Promise.resolve();
          }
        })
        .then(() => {
          this.close();
        });
    },
  },
  mounted: function () {
    bus.$on("查看描述", (e) => {
      this.init(e.temp);
    });
  },
  updated: function () {},
};
</script>

<style>
</style>